package org.jflame.web;

import jakarta.servlet.http.HttpServletRequest;

public abstract class ServletRequestContextHolder {

    private static final ThreadLocal<HttpServletRequest> ServletRequestHolder = new InheritableThreadLocal<HttpServletRequest>();

    public static HttpServletRequest getRequest() {
        return ServletRequestHolder.get();
    }

    public static void setRequest(HttpServletRequest request) {
        if (request == null) {
            throw new IllegalArgumentException("request not be null");
        }
        ServletRequestHolder.set(request);
    }

    public static void remove() {
        ServletRequestHolder.remove();
    }
}
